package com.weather.service;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import sun.net.www.protocol.http.HttpURLConnection;

public class RequestURL {
	//public static final String GET_URL = "http://m.weather.com.cn/data/101010100.html";
	//public static final String GET_URL="http://www.weather.com.cn/data/sk/101010100.html";
	//public static final String GET_URL="http://tianqi.cncn.com/beijing";
	//public static final String GET_URL ="http://www.weather.com.cn/data/cityinfo/101010100.html";
	//http://weather.china.com.cn/forecast/2-1-1.html
	//public static final String GET_URL="http://weather.51wnl.com/weatherinfo/GetMoreWeather?cityCode=101010100&weatherType=0";
	
	static String lines; 
	 public static String RequestWeathers(String URLstr) throws Exception{
		 URL url=null;
			String inputline="";
			String json="";
		 try {
				url= new URL(URLstr);
				HttpURLConnection conn=(HttpURLConnection) url.openConnection();
				conn.setRequestMethod("GET");
				InputStreamReader inReader=new InputStreamReader(conn.getInputStream(),"utf-8");
				BufferedReader bufferedReader=new BufferedReader(inReader);
				while((inputline=bufferedReader.readLine())!=null){
					json+=inputline;
				}
			} catch (MalformedURLException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return 	json;
		
	 }
	 public static void main(String[] args) throws Exception {
		 RequestWeathers("");

		}

}
